package Text01.Text;

import java.sql.*;

public class Student {
    String url = "jdbc:mysql://localhost:3306/kgc76?useSSL=false";
    Connection conn = null;
    PreparedStatement st = null;
    ResultSet rs = null;
    public void  sign (){
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try {
            conn = DriverManager.getConnection(url, "root", "root");
        } catch (SQLException e1) {
            e1.printStackTrace();
        }
    }
    public int all(){
        try {
            String sql = "SELECT COUNT(*) FROM s_student";
            st = conn.prepareStatement(sql);
            rs = st.executeQuery(sql);
            while (rs.next()){
                int i = rs.getInt(1);
                return i;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
